package com.sky.mapper;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AdminOrderMapper {
    //订单状态 1待付款 2待接单 3 已接单 4 派送中 5 已完成 6 已取消 7 退款
    List<OrderVO> historyOrders(OrdersPageQueryDTO ordersPageQueryDTO);
    @Select("select count(*) from orders where status = 3")
    Integer getConfirmedOrdersCount();

    @Select("select count(*) from orders where status = 4")
    Integer getDeliveryInProgressCount();

    @Select("select count(*) from orders where status = 2")
    Integer getToBeConfirmedCount();

    @Select("select * from orders where id = #{id}")
    OrderVO selectById(String id);

    @Update("update orders set status = 3 where id = #{id}")
    void confirm(OrdersConfirmDTO ordersConfirmDTO);

    @Update("update orders set status = 7 , rejection_reason=#{rejectionReason} where id = #{id}")
    void rejection(OrdersRejectionDTO ordersRejectionDTO);

    @Update("update orders set status = 7 , cancel_reason=#{cancelReason} where id = #{id}")
    void cancel(OrdersCancelDTO ordersCancelDTO);

    @Update("update orders set status = 4 where id = #{id}")
    void delivery(String id);

    @Update("update orders set status = 5 where id = #{id}")
    void complete(String id);
}
